package homework01;

public class Student {
private  String name;
private  int age;
private  String sex;
    //无参
    public Student() {
    }
    //有参
    public Student(String name, int age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }
//set、get方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age>=15&&age<=50) {
            this.age = age;
        }else {
            throw new AgeException("年龄异常");
        }
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
       if (sex.equals("男")&&sex.equals("女")) {
           this.sex = sex;
       }else {
           throw new SexException("性别异常");
       }
    }
}
